package com.wits.qso.dao.impl;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Component;

import com.wits.platform.dao.impl.BaseDaoImpl;
import com.wits.qso.dao.custom.ClsDaoCustom;
import com.wits.qso.entity.Cls;
import com.wits.qso.entity.Dept;
import com.wits.qso.entity.Grade;

@Component
public class ClsDaoImpl extends BaseDaoImpl<Cls, String> implements ClsDaoCustom{

	@Override
	public boolean isExitsByGradeAndDept(Grade grade, Dept dept,String clsTitle) {
		Query query=em.createQuery("FROM Cls o WHERE o.grade.gradeId = :gradeId and o.dept.id=:deptId " +
				"and clsTitle = :clsTitle");
		query.setParameter( "gradeId", grade.getGradeId() );
		query.setParameter( "deptId", dept.getId() );
		query.setParameter("clsTitle", clsTitle);
		try {
			List list=query.getResultList();
			if(list!=null && list.size()>0) 
				return true;
			else
				return false;
		} catch (Exception e) {
			return false;
		}
		
	}

}
